from django.conf.urls import url

from rest_framework_jwt.views import obtain_jwt_token
from users.views import AddressViewSet
from . import views

urlpatterns = [
    url(r'^usernames/(?P<username>\w{6,20})/count/$', views.RegisterUserNameCountAPIView.as_view()),
    url(r'^phones/(?P<mobile>1[3-9]\d{9})/count/$', views.RegisterMobileCountAPIView.as_view()),
    # url(r'^auths/', obtain_jwt_token, name='auths'),  # jwt 设置代码在utils里
    url(r'^auths/', views.UserAuthorizationView.as_view(), name='auths'),  # 登陆视图

    url(r'^$', views.RegisterCreateView.as_view(), name='register'),
    url(r'^infos/$', views.UserDetailView.as_view(), name='detail'),
    url(r'^emails/$', views.EmailView.as_view(), name='send_mail'),
    url(r'^emails/verification/', views.VerifyEmailView.as_view(), name='verify'),
    # /users/browerhistories/  添加历史记录
    url(r'^browerhistories/$', views.UserBrowsingHistoryView.as_view(), name='history'),
]

from rest_framework.routers import DefaultRouter
router = DefaultRouter()
# 添加收货地址增删改的路由
router.register(r'addresses',AddressViewSet,base_name='address')
urlpatterns += router.urls